import java.util.*;

public class Class4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i=0;i<n;i++){
            nums[i] = scanner.nextInt();
        }
        if(n==1){
            System.out.println(nums[0]);
            return;
        }
        if (n==2){
            System.out.println(nums[0]+nums[1]);
            return;
        }
        int sum =0;
        for (int len=1;len<=n;len+=2){
            int start = 0;
            for (;start<=n-len;start++){
                int end = start+len;
                List<Integer> list = new ArrayList<>();
                for (int i=start;i<end;i++){
                    list.add(nums[i]);
                }
                Collections.sort(list);
                sum+= list.get(list.size()/2);
            }
        }
        System.out.println(sum);


    }
}
